#!/usr/bin/python
# Copyright 2011, Kitware, Inc.

import SimpleITK as sitk

# Create Images
image = sitk.Image(256, 256, 256, sitk.sitkInt16)
twoD = sitk.Image(64, 64, sitk.sitkFloat32)

# Pixel Access
print image.GetPixel(0, 0, 0)
image.SetPixel(0, 0, 0, 1)
print image.GetPixel(0, 0, 0)

# Syntactic Sugar
print image[0, 0, 0]
image[0, 0, 0] = 10
print image[0, 0, 0]

# Some filters change type
print image.GetPixelIDTypeAsString()
smooth = sitk.SmoothingRecursiveGaussian(image, 2.0)

# Casting
print "Before: ", smooth.GetPixelIDTypeAsString()
smooth = sitk.Cast(smooth, image.GetPixelIDValue())
print "After: ", smooth.GetPixelIDTypeAsString()
sitk.Show(sitk.Subtract(image, smooth), "DiffWithGaussian")

# Extract image regions
size = [64, 64, 0]
start = [64, 0, 0]
sitk.Show(sitk.Extract(image, size, start), "Extracted")
